<div id="tracker-webhooks">
    <h3>{{# dgettext }} tuleap-tracker | Webhooks {{/ dgettext }}</h3>

    <p class="tracker-webhooks-desc">
        {{# dgettext }} tuleap-tracker | You can define several webhooks that will be processed after each artifact creation and updates. {{/ dgettext }}
        <span class="tracker-webhooks-desc-warn text-warning">
        <i class="fa fa-exclamation-triangle"></i> {{# dgettext }} tuleap-tracker | Be careful, all the artifact content is sent in the payload without permission checks. {{/ dgettext }}
    </span>
    </p>

    <button
        type="button"
        class="btn btn-primary create-tracker-webhook-btn"
        data-toggle="modal"
        href="#modal-create-webhook"
    >
        <i class="fa fa-plus"></i> {{# dgettext }} tuleap-tracker | Add webhook {{/ dgettext }}
    </button>

    <table class="table tracker-webhooks-list">
        <thead>
        <tr>
            <th>{{# dgettext }} tuleap-tracker | URL {{/ dgettext }}</th>
            <th>{{# dgettext }} tuleap-tracker | Last push {{/ dgettext }}</th>
            <th></th>
        </tr>
        </thead>
        <tbody>
        {{# webhook_presenters }}
            <tr>
                <td>{{ webhook_url }}</td>
                <td class="last-push">
                    {{# last_log }}
                        {{# status_ok }}
                            <span class="text-success" title="{{ status_message }}">
                            <i class="fa fa-check-circle"></i> {{ status_message }}
                         </span>
                        {{/ status_ok }}

                        {{^ status_ok }}
                            <span class="text-warning" title="{{ status_message }}">
                            <i class="fa fa-exclamation-triangle"></i> {{ status_message }}
                         </span>
                        {{/ status_ok }}
                    {{/ last_log }}
                </td>
                <td class="action-buttons">
                    <a role="button" data-toggle="modal" href="#modal-logs-{{ webhook_id }}">
                        <i class="fa fa-list"></i> {{# dgettext }} tuleap-tracker | Logs {{/ dgettext }}
                    </a>
                    <a role="button" data-toggle="modal" href="#modal-edit-webhook-{{ webhook_id }}">
                        <i class="fa fa-pencil-square-o"></i> {{# dgettext }} tuleap-tracker | Edit {{/ dgettext }}
                    </a>
                    <a href="javascript:;"
                       class="remove-tracker-webhook"
                       data-toggle="popover"
                       data-trigger="click"
                       data-placement="left"
                       data-html="true"
                       data-popover-id="remove-{{ webhook_id }}-popover"
                    >
                        <i class="fa fa-trash-o"></i> {{# dgettext }} tuleap-tracker | Remove {{/ dgettext }}
                    </a>

                    {{> modal-logs }}
                    {{> popover-remove-webhook }}
                </td>
            </tr>
        {{/ webhook_presenters }}

        {{^ webhook_presenters }}
            <tr>
                <td class="table-cell-empty" colspan="3">
                    {{# dgettext }} tuleap-tracker | No webhooks defined {{/ dgettext }}
                </td>
            </tr>
        {{/ webhook_presenters }}
        </tbody>
    </table>
</div>

{{> modal-create-webhook }}

{{# webhook_presenters }}
    {{> modal-edit-webhook }}
{{/ webhook_presenters }}
